package cn.hdu.liang.typeinfo.toys;

import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

class SuperToy extends FancyToy {
    int IQ;

    public SuperToy(int iq) {
        IQ = iq;
    }

    @Override
    public String toString() {
        return "SuperToy, 我的智商 " + IQ;
    }
}

public class Exam19 {
    public static void main(String[] args) throws ClassNotFoundException, IllegalAccessException, InvocationTargetException, InstantiationException {
        Class<?> aClass = Class.forName("cn.hdu.liang.typeinfo.toys.SuperToy");
        Constructor<?>[] cons = aClass.getConstructors();
        for(Constructor<?> ctor : cons) {
            Class<?>[] params = ctor.getParameterTypes();
            if(params.length == 1 && params[0] == int.class) {
                System.out.println(ctor.newInstance(new Object[]{Integer.valueOf(120)}));
            }
        }
    }
}
